Ext.onReady(function(){
	StartFlowManager.initPage();
});

var StartFlowManager = {
		initPage: function(){
			Ext.create('Ext.container.Viewport', {
			    layout: 'border',
			    frame:false,
			    border:false,
			    items: [{
			    	id: 'mainPanel',
			        region: 'center',
			        layout: 'fit',
			        items:[StartFlowManager.createFlowGrid()]
			    }]
			});
		},
		createFlowGrid: function(){
			var grid = Ext.create('Ext.com.bkfm.datagrid', {
				id: "flowGrid",
				objPath : "ROOT/WORKFLOW/LCGL/BLK_WORKFLOW_DEPLOYED",
				hiddenField: ['WORKFLOW_CONFIG'],
				formUnViewField: ["WORKFLOW_CONFIG"],
				showstandardBtn: false,
				tbar:[/*{
					text: "编辑",
					iconCls: 'edit',
					handler: function(){
						var record = grid.getSelectedRecord();
						if(record == null){
							return ;
						}
						var win = Ext.create('Ext.com.bkfm.window', {
							title : "编辑",
							autoScroll : true,
							modal : true,
							height : Utils.getHeight()*0.8,
							width : Utils.getWidth()*0.7,
							items:[Ext.create('Ext.com.bkfm.form', {
								showGroup : false,
								border : false,
								frameborder : false,
								objPath : "ROOT/WORKFLOW/LCGL/BLK_WORKFLOW_DEPLOYED",
								textOnlyField: ['WORKFLOW_CODE'],
								unViewField: ['WORKFLOW_CONFIG'],
								listeners:{
									render: function(form){
										form.loadRemoteData(record.getId());
									}
								},
								tbar:[{
									text: "保存",
									iconCls: "save",
									handler: function(self){
										var form = self.ownerCt.ownerCt;
										form.save(function(){
											AjaxUtils.showInfo("操作成功",function(){
												grid.reload();
												win.close();
											})
										});
									}
								},{
									text: "关闭",
									iconCls: "close",
									handler: function(){
										win.close();
									}
								}]
							})]
						}).show();
					}
				}*/{
					text: "启动",
					iconCls: "start",
					handler: function(){
						var record = grid.getSelectedRecord();
						if(record == null){
							return ;
						}
						WORKFLOW_MANAGER.startWorkFlowProcess({
							workflow_code: record.get("WORKFLOW_CODE"),
							workflow_deployed_id: "",
							workflow_deployed_name: "",
							workflow_request_id: "",
							workflow_request_name: "",
							call: function(){
								
							}
						});
						
					}
				}]
			});
			return grid;
		}
};